<?php

class My_Controller_Plugin extends Zend_Controller_Plugin_Abstract{

    private function _setLayout($module = 'default')
    {
        $layout = Zend_Layout::getMvcInstance();
        $app = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH.'/configs/application.ini');
        $options = $app->bootstrap()->getOptions();
        $layoutPathTemp = $options['resources']['layout']['layoutPath'];
        $layoutPage = $options['resources']['layout']['layout'];
        $layoutPath = $layoutPathTemp.'/'.$module;
        
        $layout->setLayoutPath($layoutPath);
        $layout->setLayout($layoutPage);
        //view = new Zend_View();

        /*$layoutPath = $layoutPath;
        $option = array ('layout' => $layoutPage,'layoutPath' => $layoutPath );
        Zend_Layout::startMvc ( $option );*/
    }

    public function preDispatch(Zend_Controller_Request_Abstract $request)
    {
        $this->_setLayout($request->getModuleName());
    }
}
?>
